package com.tanhua.admin.controller;

import com.tanhua.admin.service.ManageService;
import com.tanhua.model.vo.PageResult;
import com.tanhua.model.vo.UserInfoVoAge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/manage")
public class ManageController {

    @Autowired
    private ManageService manageService;

    /**
     * 用户管理 分页查询
     * @param page
     * @param pageSize
     * @return
     */
    @GetMapping("/users")
    public ResponseEntity findPage(@RequestParam(defaultValue = "1") Long page,
                                   @RequestParam(defaultValue = "10",value = "pagesize") Long pageSize) {
        PageResult result = manageService.findPage(page,pageSize);
        return ResponseEntity.ok(result);
    }

    /**
     * 查询用户详情
     * @return
     */
    @GetMapping("/users/{userId}")
    public ResponseEntity getUserInfo(@PathVariable Long userId){
        UserInfoVoAge vo = manageService.findById(userId);
        return ResponseEntity.ok(vo);
    }

    /**
     * 查询指定用户发布的所有视频列表
     */
    @GetMapping("/videos")
    public ResponseEntity videos(@RequestParam(defaultValue = "1") Long page,
                                 @RequestParam(defaultValue = "10") Long pagesize,
                                 Long uid ) {
        PageResult result = manageService.findAllVideos(page,pagesize,uid);
        return ResponseEntity.ok(result);
    }

    //查询动态
    @GetMapping("/messages")
    public ResponseEntity messages(@RequestParam(defaultValue = "1") Long page,
                                   @RequestParam(defaultValue = "10") Long pagesize,
                                   Long uid,Integer state) {
        PageResult result = manageService.findAllMovements(page,pagesize,uid,state);
        return ResponseEntity.ok(result);
    }

}
